package com.haoran.dwz.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.haoran.dwz.model.Server;
import com.haoran.dwz.rest.R;
import com.haoran.dwz.service.ServiceDiscovery;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@Api(tags = { "Service Discovery" }, description = "服务发现模块", position = 0)
public class ServiceDiscoveryController {

	@Autowired
	private ServiceDiscovery serviceDiscovery;

	@ApiOperation("根据服务名称找服务地址")
	@RequestMapping(value = "getServiceList", method = RequestMethod.GET)
	public R getServiceList(@ApiParam("服务名称 ") @RequestParam String serviceName) {

		List<Server> serverList = serviceDiscovery.getServerList(serviceName);
		return R.success(serverList);
	}
}
